package com.monitor.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.monitor.entity.ErpSaleRepairSale;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 销售维修-销售表 Mapper 接口
 * </p>
 *
 * @author LX
 * @since 2018-09-12
 */
public interface ErpSaleRepairSaleMapper extends BaseMapper<ErpSaleRepairSale> {
	@Select("SELECT count(1) from erp_sale_repair_sale srs, erp_sale_repair_order sro where srs.order_id=sro.id and srs.materiel_out_to not like #{outTo} and sro.customer_name=#{cusNames} and sro.sale_repair_date>=#{startTime} and sro.sale_repair_date<#{endTime}")
	public Integer selectSizeByCustNameAndOutto(@Param("outTo")String outTo,@Param("cusNames")String cusNames,@Param("startTime")String startTime,@Param("endTime")String endTime);
	/////这个好像接值接不到,
	@Select("SELECT SUM(s.materiel_number) a0, SUM(s.materiel_total)  a1, s.materiel_name  a2 FROM  erp_sale_repair_sale s WHERE 	( s.materiel_name LIKE '%轮胎%' OR s.materiel_name LIKE '%轮辋%' OR s.materiel_name LIKE '%机油%' OR s.materiel_name LIKE '%柴油%' ) 	AND s.order_id in (#{sroId}) GROUP BY s.materiel_name")
	public List<Map<String,Object>> selectBySroIds(@Param("sroId")String sroId);
	
	@Select("select sum(mfm.materiel_number),sum(mfm.materiel_total),mfm.materiel_name from erp_materiel_flow_materiel mfm where mfm.materiel_flow_id in (${matFlowId})  group by  mfm.materiel_name")
	public List<Map<String,Object>> selectByFlowId(@Param("matFlowId")String matFlowId);
}
